/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink.device;

import com.xpstem.lelink.EventBus;
import com.xpstem.lelink.enums.InputPort;

import java.util.HashMap;
import java.util.Map;

/**
 * EV3 ultrasonic sensor
 *
 * @author billy zhang
 */
public class EV3UltrasonicSensor extends EV3Sensor {

    /**
     * TYPE
     */
    public static final short TYPE = 30;

    /**
     * 测量 - 距离 - 厘米
     */
    public static final short MODE_CM = 0;
    /**
     * 测量 - 距离 - 英寸
     */
    public static final short MODE_INCH = 1;
    /**
     * 测量 - 存在
     * 侦听其他超声波信号，如检测到信息，输出为"真"，否则为"伪"
     */
    public static final short MODE_LISTEN = 2;

    /**
     * 比较？
     */
    public static final short MODE_SI_CM = 3;

    public static final short MODE_SI_INCH = 4;

    /**
     * 高级？
     */
    public static final short MODE_DC_CM = 5;

    public static final short MODE_DC_INCH = 6;

    private static Map<Short, String> modeMap;
    static {
        modeMap = new HashMap<>();
        modeMap.put(MODE_CM, "CM");
        modeMap.put(MODE_INCH, "Inch");
        modeMap.put(MODE_LISTEN, "Listen");
        modeMap.put(MODE_SI_CM, "SI CM");
        modeMap.put(MODE_SI_INCH, "SI Inch");
        modeMap.put(MODE_DC_CM, "DC CM");
        modeMap.put(MODE_DC_INCH, "DC Inch");
    }

    public EV3UltrasonicSensor(EventBus eventBus, InputPort portNo, short mode) {
        super(eventBus, portNo, "Ultrasonic Sensor", TYPE, mode);
    }

    @Override
    public Map<Short, String> getModeMap() {
        return modeMap;
    }
}
